#-------------------------------------------------
#
# Project created by QtCreator 2015-08-01T00:00:11
#
#-------------------------------------------------

QT += core gui xml qml quick concurrent \
#   axcontainer

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

FRAMEWORK_ROOT = $$PWD/../../..

include($${FRAMEWORK_ROOT}/source/common/config.pri)
include($${FRAMEWORK_ROOT}/source/common/build.pri)

TEMPLATE = app
TARGET = $$qtLibraryTarget(jdataanalyse)
DESTDIR = $${FRAMEWORK_ROOT}/bin

DEFINES += \
#    USE_JOFFICE \
    USE_JWIDGETS \
    USE_JCURVE \
    USE_JFILEPARSE \
    USE_JMYOFFICE \
    USE_JSQL \
    USE_QWT \
    USE_ENCRYPT

##########
DEFINES += APP_LOG
##########

## - import libraries -

## sources

INCLUDEPATH += $$PWD

HEADERS += \
    mainwindow.h \
    centralwidget.h \
    startpagemgr.h \
    statusbarmgr.h \
    data_manager/datamgrwidget.h \
    data_query/dataquerywidget.h \
    data_analyse/dataanalysewidget.h \
    data_manager/dataqueryanddisplay.h \
    data_manager/dataimportmgr.h \
    data_manager/databasemgr.h \
    data_manager/rulemgrwidget.h \
    modelmgrwidget.h \
    customtype.h \
    data_query/siftareasettings.h \
    globalconfig.h \
    data_analyse/jlistcoorditem.h \
    data_analyse/jcurvegroupwidget.h \
    data_manager/databasesampling.h \
    jbusyindicator.h \
    licensedialog.h \
    accountmgr.h \
    logviewmgr.h \
    securitmgr.h

SOURCES += \
    main.cpp \
    mainwindow.cpp \
    centralwidget.cpp \
    startpagemgr.cpp \
    statusbarmgr.cpp \
    data_manager/datamgrwidget.cpp \
    data_query/dataquerywidget.cpp \
    data_analyse/dataanalysewidget.cpp \
    data_manager/dataqueryanddisplay.cpp \
    data_manager/dataimportmgr.cpp \
    data_manager/databasemgr.cpp \
    data_manager/rulemgrwidget.cpp \
    modelmgrwidget.cpp \
    data_query/siftareasettings.cpp \
    globalconfig.cpp \
    data_analyse/jlistcoorditem.cpp \
    data_analyse/jcurvegroupwidget.cpp \
    data_manager/databasesampling.cpp \
    jbusyindicator.cpp \
    licensedialog.cpp \
    accountmgr.cpp \
    logviewmgr.cpp \
    securitmgr.cpp

RESOURCES += \
    resource/application.qrc

##################################################
## import libraries
##################################################

# com.smartsoft.jsmartkits.joffice

contains(DEFINES, USE_JMYOFFICE) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice -lcom.smartsoft.jsmartkits.joffice
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice -lcom.smartsoft.jsmartkits.jofficed
    else:macx: LIBS += -framework com.smartsoft.jsmartkits.joffice -F$${FRAMEWORK_ROOT}/lib/
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice -lcom.smartsoft.jsmartkits.joffice

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice/include
    }
    DEFINES += JOFFICE_DLL
}

# com.smartsoft.jsmartkits.jwidgets

contains(DEFINES, USE_JWIDGETS) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets -lcom.smartsoft.jsmartkits.jwidgets
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets -lcom.smartsoft.jsmartkits.jwidgetsd
    else:macx: LIBS += -framework com.smartsoft.jsmartkits.jwidgets -F$${FRAMEWORK_ROOT}/lib/
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets -lcom.smartsoft.jsmartkits.jwidgets

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets/include
    }
    DEFINES += JWIDGETS_DLL
}

# qwt

contains(DEFINES, USE_QWT) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/core/qwt -lqwt
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/core/qwt -lqwtd
    else:macx: LIBS += -framework qwt -F$${FRAMEWORK_ROOT}/lib/core/
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/core/qwt -lqwt

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/core/qwt.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/core/qwt.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/core/qwt/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/core/qwt/include
    }
    DEFINES += QWT_DLL
}

# jplugins.curve

contains(DEFINES, USE_JCURVE) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve -ljplugins.curve
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve -ljplugins.curved
    else:macx: LIBS += -framework jplugins.curve -F$${FRAMEWORK_ROOT}/lib/plugins
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve -ljplugins.curve

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve/include
    }
    DEFINES += JCURVE_DLL
}

# jplugins.fileparse

contains(DEFINES, USE_JFILEPARSE) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse -ljplugins.fileparse
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse -ljplugins.fileparsed
    else:macx: LIBS += -framework jplugins.fileparse -F$${FRAMEWORK_ROOT}/lib/plugins
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse -ljplugins.fileparse

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse/include
    }
    DEFINES += JFILEPARSE_DLL
}

# jplugins.office

contains(DEFINES, USE_JMYOFFICE) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.office -ljplugins.office
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.office -ljplugins.officed
    else:macx: LIBS += -framework jplugins.office -F$${FRAMEWORK_ROOT}/lib/plugins
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.office -ljplugins.office

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.office.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.office.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.office/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.office/include
    }
    DEFINES += JMYOFFICE_DLL
}

# jplugins.sql

contains(DEFINES, USE_JSQL) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql -ljplugins.sql
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql -ljplugins.sqld
    else:macx: LIBS += -framework jplugins.sql -F$${FRAMEWORK_ROOT}/lib/plugins
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql -ljplugins.sql

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql/include
    }
    DEFINES += JSQL_DLL
}

# encrypt

contains(DEFINES, USE_ENCRYPT) {
    win32:CONFIG(release, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/core/encrypt -lencrypt
    else:win32:CONFIG(debug, debug|release): LIBS += -L$${FRAMEWORK_ROOT}/lib/core/encrypt -lencryptd
    else:macx: LIBS += -framework encrypt -F$${FRAMEWORK_ROOT}/lib/core
    else:unix: LIBS += -L$${FRAMEWORK_ROOT}/lib/core/encrypt -lencrypt

    macx:{
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/core/encrypt.framework/Versions/Current/Headers
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/core/encrypt.framework/Versions/Current/Headers
    } else {
        INCLUDEPATH += $${FRAMEWORK_ROOT}/lib/core/encrypt/include
        DEPENDPATH += $${FRAMEWORK_ROOT}/lib/core/encrypt/include
    }
    DEFINES += ENCRYPT_DLL
}

## copy libraries

copyCommand = @echo ---- module $${TARGET}: copy libraries ----

macx: {
    ##
} else:win32|unix: {

    destdir = $${FRAMEWORK_ROOT}/bin
    srcfiles =

    ## lib-suffix
    win32:CONFIG(debug, debug|release):lib_suffix=d.dll
    else:win32:CONFIG(release, debug|release):lib_suffix=.dll
    else:unix:lib_suffix=.so

    win32:destdir = $$replace(destdir, /, \\)

    # com.smartsoft.jsmartkits.joffice
    srcfiles += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.joffice/com.smartsoft.jsmartkits.joffice
    # com.smartsoft.jsmartkits.jwidgets
    srcfiles += $${FRAMEWORK_ROOT}/lib/com.smartsoft.jsmartkits.jwidgets/com.smartsoft.jsmartkits.jwidgets
    # qwt
    srcfiles += $${FRAMEWORK_ROOT}/lib/core/qwt/qwt
    # jplugins.curve
    srcfiles += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.curve/jplugins.curve
    # jplugins.fileparse
    srcfiles += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.fileparse/jplugins.fileparse
    # jplugins.office
    srcfiles += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.office/jplugins.office
    # jplugins.sql
    srcfiles += $${FRAMEWORK_ROOT}/lib/plugins/jplugins.sql/jplugins.sql
    ## copy files
    for (srcfile, srcfiles) {
        srcfile = $$srcfile$${lib_suffix}
        exists("$$srcfile"): {
            win32:srcfile = $$replace(srcfile, /, \\)
            copyCommand += && $(COPY_FILE) "$$srcfile" "$$destdir"
        }
    }
}

first.depends = $(first)
application.commands = $$copyCommand
first.depends += application

QMAKE_EXTRA_TARGETS += first \
    application

DISTFILES += \
    resource/qml/JBusyIndicator.qml
